﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharepointSolutionInstaller.Resources;
using SharepointSolutionInstaller.Views;
using SharepointSolutionInstaller.Utils.Configuration;


namespace SharepointSolutionInstaller.Utils.SolutionDeployment
{

    /// <summary>
    /// Command that registers the version number of a solution.
    /// </summary>
    public class RegisterVersionNumberCommand : Command
    {
        private Version oldVersion;

        internal RegisterVersionNumberCommand(InstallProcess parent) : base(parent) { }

        internal override string Description
        {
            get
            {
                return CommonUIStrings.registerVersionNumberCommand;
            }
        }

        protected internal override bool Execute()
        {
            oldVersion = InstallConfiguration.InstalledVersion;
            InstallConfiguration.InstalledVersion = InstallConfiguration.SolutionVersion;
            return true;
        }

        protected internal override bool Rollback()
        {
            InstallConfiguration.InstalledVersion = oldVersion;
            return true;
        }
    }
}
